package com.jinxin.platform.cdqzsqacs.service.impl;

import com.jinxin.platform.cdqzsqacs.service.GaUploadService;
import com.jinxin.platform.cdqzsqacs.task.ResultEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture;

import java.util.concurrent.Future;

/**
 * All rights Reserved, Designed By www.beonelot.com
 *
 * @version: V1.0
 * @Copyright: www.beonelot.com Inc. All rights reserved.
 * @Description：
 * @Date: 2021-06-24
 * @Author: Lingnan
 **/
@Component
@Slf4j
public class GaUploadAsyncService {
    @Autowired
    private GaUploadService gaUploadService;
    /**
     * @Async注解表示异步，后面的参数对应于线程池配置类ExecutorConfig中的方法名asyncServiceExecutor()，
     * 如果不写后面的参数，直接使用@Async注解，则是使用默认的线程池
     * Future<Object>为异步返回的结果。可以通过get()方法获取结果。
     *
     */
    @Async("asyncServiceExecutor")
    public void gaUploadData(String type, String json,boolean hasImg,String imgUrl){
        log.info("上传数据至公安平台开始异步执行");
        ResultEntity resultEntity = gaUploadService.incoming(type, json,hasImg,imgUrl);
        log.info("上传数据至公安平台开始异步执行，执行结果: " + resultEntity.toString());
//        ResultEntity resultEntity = new ResultEntity();
//        resultEntity.setCode(0);
    }

}
